﻿using System.Drawing;
using Medicalsystem.MCP.FormDesigner.Ctl;

namespace Medicalsystem.MCP.FormDesigner
{
    /// <summary>
    ///控件捏手的处理方法-捏手控制控件的Size
    /// </summary>
    public class UIMoveKnob
    {
        private CtrlMngDesign _ctrlMngDesign;
        private ctl_UIMoveDot _UIMoveDot; //移动捏有由外部创建

        /// <summary>
        ///
        /// </summary>
        /// <param name="ctrlMngDesign">控件管理者</param>
        public UIMoveKnob(CtrlMngDesign ctrlMngDesign)
        {
            this._ctrlMngDesign = ctrlMngDesign;
            this._UIMoveDot = new ctl_UIMoveDot();
            this._ctrlMngDesign.ParentContainer.Container.Controls.Add(_UIMoveDot);
            SetUIMoveDotPosition();
        }

        /// <summary>
        /// 属于的控件管理者
        /// </summary>
        public CtrlMngDesign ctrlMngDesign
        {
            get { return _ctrlMngDesign; }
        }

        /// <summary>
        /// 移动捏手
        /// </summary>
        public ctl_UIMoveDot UIMoveDot
        {
            get { return _UIMoveDot; }
        }

        /// <summary>
        /// 注销
        /// </summary>
        public void Dispose()
        {
            if (_UIMoveDot != null)
            {
                _UIMoveDot.Dispose();
            }
        }

        /// <summary>
        /// 将控件带到 Z 顺序的前面
        /// </summary>
        public void BringToFront()
        {
            if (_UIMoveDot != null)
            {
                _UIMoveDot.BringToFront();
            }
        }

        /// <summary>
        /// 设置移动捏手位置
        /// </summary>
        public void SetUIMoveDotPosition()
        {
            if (_UIMoveDot != null)
            {
                _UIMoveDot.Location = new Point(this._ctrlMngDesign.Owner.Left + _UIMoveDot.Width / 2, this._ctrlMngDesign.Owner.Top - _UIMoveDot.Height / 2);
            }
        }
    }
}